package com.hrm.model.daoimple;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.hrm.model.dao.OrgDAO;
import com.hrm.model.dto.org.OrgBaseDTO;
import com.hrm.model.dto.org.OrgCountDTO;
import com.hrm.model.dto.org.OrgPersonDTO;
import com.hrm.model.dto.org.OrgViewDTO;
import com.hrm.model.dto.org.TreeDTO;

public class OrgDAOImple extends SqlMapClientDaoSupport implements OrgDAO{

	@Override
	public List<OrgBaseDTO> getAllOrgbase() {
		return this.getSqlMapClientTemplate().queryForList("OrgMap.getAllOrgbase");
	}

	@Override
	public OrgCountDTO getOrgCount(OrgViewDTO dto) {
		return (OrgCountDTO)this.getSqlMapClientTemplate().queryForObject("OrgMap.getOrgCount", dto);
	}

	@Override
	public List<OrgViewDTO> getOrgView(OrgViewDTO dto) {
		return this.getSqlMapClientTemplate().queryForList("OrgMap.getOrgView", dto);
	}

	@Override
	public OrgBaseDTO getOrgbase(OrgBaseDTO dto) {
		return (OrgBaseDTO)this.getSqlMapClientTemplate().queryForObject("OrgMap.getOrgbase", dto);
	}

	@Override
	public List<TreeDTO> getTree(String time) {		
		return this.getSqlMapClientTemplate().queryForList("OrgMap.getTree", time);
	}

	@Override
	public boolean insertOrgBase(OrgBaseDTO dto) {
		try {
			this.getSqlMapClientTemplate().insert("OrgMap.insertOrgbase", dto);
			return true;
		} catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}
	}

	@Override
	public boolean updateOrgBase(OrgBaseDTO dto) {
		try {
			this.getSqlMapClientTemplate().update("OrgMap.updateOrgbase", dto);
			return true;
		} catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}
	}

	@Override
	public boolean endOrgBase(OrgBaseDTO dto) {
		try {
			this.getSqlMapClientTemplate().update("OrgMap.endOrgbase", dto);
			return true;
		} catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}
	}

	@Override
	public boolean endOrgperson(OrgPersonDTO dto) {
		try{
			this.getSqlMapClientTemplate().update("OrgMap.endOrgperson", dto);
			return true;
		}catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}
		
	}

	@Override
	public boolean insertOrgperson(OrgPersonDTO dto) {
		try{
			this.getSqlMapClientTemplate().update("OrgMap.insertOrgperson", dto);
			return true;
		}catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}

	}




	
	
	

}
